package net.csdn.business.notify.handler.service.impl;

import com.google.common.collect.Lists;
import net.csdn.business.notify.common.model.vo.UserInfoVO;
import net.csdn.business.notify.feign.SystemFeignClient;
import net.csdn.business.notify.handler.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author zhangyl
 * @Date 2023/12/1 11:45
 */

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private SystemFeignClient systemFeignClient;

    @Override
    public Map<String, UserInfoVO> getUserInfo(List<String> userIds) {
        Map<String, UserInfoVO> reslt=new HashMap<>();
        if(userIds!=null&&userIds.size()>0){
            //由于authing接口限制，每次查询50个
            List<List<String>> uidBathList=Lists.partition(userIds, 50);
            for (List<String> userIdList:uidBathList){
                //批量查询用户信息
                Map<String, UserInfoVO> userinfos= systemFeignClient.batchQuery(userIdList);
                reslt.putAll(userinfos);
            }
        }
        return reslt;
    }
}
